#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
	for (int i = 1; i < 10001; i++)
	{
		int count = 0;
		int j = i;
		while ( j != 0)
		{
			count++;
			j = j / 10;
		}
		j = i;
		int shu=0;
		while(j!=0)
		{
		    shu +=pow(j%10, count);
			j=j / 10;
		}
		if (shu == i)
		{
			printf("%d\n", shu);
		}
	}
	return 0;
}